<template>
    <div>
        <Form :label-width="100" inline>
            <Form-item label="属地区划:">
                <area-linkage :areaCode.sync="queryParam.ssde0009" :countyDisable=countyState :streetDisable=streetState
                              :communityDisable=communityState></area-linkage>
            </Form-item>
            <Form-item label="人员姓名:">
                <Input v-model="queryParam.ssde0001" placeholder="请输入人员姓名" style="width:160px"/>
            </Form-item>
            <Form-item label="身份证号码:">
                <Input v-model="queryParam.ssde0002" placeholder="请输入身份证号码" style="width:200px"/>
            </Form-item>
            <Form-item label="救助对象类别:">
                <Select v-model="queryParam.ssde0008" style="width:150px">
                    <Option value="1010">城市低保对象</Option>
                    <Option value="1020">城市低保边缘家庭</Option>
                    <Option value="1030">农村低保对象</Option>
                    <Option value="1040">农村低保边缘家庭</Option>
                </Select>
            </Form-item>
            <Form-item label="专项救助类别:">
                <Select v-model="queryParam.ssde0004" style="width:150px">
                    <Option value="3070">电价补贴对象</Option>
                    <Option value="3080">价格补贴对象</Option>
                </Select>
            </Form-item>
            <Form-item label="救助标准类别:">
                <Select v-model="queryParam.ssde0005" style="width:100px">
                    <Option value="1">按人</Option>
                    <Option value="2">按户</Option>
                </Select>
            </Form-item>
            <Form-item label="救助年月:">
                <DatePicker type="month" v-model="queryParam.ssde0003" placeholder="请选择救助年月" format="yyyy-MM"
                            style="width: 200px"  :editable="false"></DatePicker>
            </Form-item>
            <Form-item label="救助标准:">
                <Input v-model="queryParam.ssde0006" placeholder="请输入救助标准" style="width: 200px" number/>
            </Form-item>
            <Form-item label="救助金额:">
                <Input v-model="queryParam.ssde0007" placeholder="请输入救助金额" style="width: 200px" number/>
            </Form-item>
            <Form-item label="银行账号:">
                <Input v-model="queryParam.ssde0016" placeholder="请输入银行账号" style="width:200px"/>
            </Form-item>
            <Row class="button_row">
                <span style="float: left;">
                  <Button type="primary" class="button_item_left" @click="handleAdd()">录入</Button>
                  <Button type="primary" class="button_item_left" @click="handleEdit()">编辑</Button>
                  <Button type="primary" class="button_item_left" @click="handleDelete()">删除</Button>
                  <Button type="primary" class="button_item_left" @click="handleView()">详情</Button>
                  <Button type="primary" class="button_item_left" @click="generate()" v-if="showGenerate">批量生成</Button>
                </span>
                <span style="float: right;">
                 <Button type="primary" @click="searchQuery13008">查询</Button>
                 <Button type="primary" class="button_item_left" @click="searchReset">重置</Button>
                </span>
            </Row>
        </Form>

        <div>
            <modal01 ref="modal01" @ok="ok"></modal01>
            <modal02 ref="modal02" @ok="ok"></modal02>
        </div>

        <div class="table_div">
            <vxe-table border
                       resizable
                       row-id="id"
                       :row-key="true"
                       show-overflow="tooltip"
                       align="center"
                       header-align="center"
                       ref="xTree"
                       :loading="Loading"
                       :radio-config="{highlight: true}"
                       @cell-click="selectChange"
                       :data="tableData">
                <vxe-table-column type="radio" width="60" align="center" fixed="left"/>
                <vxe-table-column field="ssde0004_name" title="专项救助类别" align="center" width="150" fixed="left"/>
                <vxe-table-column field="ssde0001" title="姓名" align="center" width="120" fixed="left"/>
                <vxe-table-column field="ssde0002" title="身份证号码" align="center" width="200" fixed="left"/>
                <vxe-table-column field="azaa0002" title="属地区划" align="center" width="300" fixed="left"/>
                <vxe-table-column field="ssde0008_name" title="救助对象类别" align="center" width="150"/>
                <vxe-table-column field="ssde0005_name" title="救助标准类别" align="center" width="150"/>
                <vxe-table-column field="ssde0003" title="救助年月" align="center" width="150" :formatter="Time1"/>
                <vxe-table-column field="ssde0006" title="救助标准" align="center" width="150"/>
                <vxe-table-column field="ssde0007" title="救助金额" align="center" width="150"/>
                <vxe-table-column field="ssde0016" title="银行账号" align="center" width="200"/>
            </vxe-table>
            <Page :total="dataCount" :page-size="pageSize" show-total class="paging"
                  @on-change="handleTableChange" :current="pageNo"></Page>
        </div>

    </div>
</template>

<script>
    import {postAction} from '@/api/request'
    import {CommonMixin} from '@/views/common/js/CommonMixin'
    import DateFormat from '@/plugins/format.js'
    import {IdentityCodeValid} from '@/plugins/idcardValid.js'
    import modal01 from './modules/modal01.vue'
    import modal02 from './modules/modal02.vue'


    export default {
        mixins: [CommonMixin],
        components: {
            modal01,
            modal02
        },
        data() {
            return {
                countyState: false,
                streetState: false,
                communityState: false,
                tableData: [],
                Loading: false,
                url: {
                    list: "/api/ac/subsistence/ss13008Service/getPageList",
                    delete: "/api/ac/subsistence/ss13008Service/deleteData",
                },
                formData: {
                },
                queryParam: {},
                visible: false,
                visible02: false,
                showSubmit: true,
                dataCount: 0,
                pageSize: 10,
                modal: false,
                title: "",
                ssde0006Return: null,
                disableSubmit02: false,
                showGenerate: false,
            }
        },
        methods: {
            searchQuery13008(){
                this.queryParam.ssde0003 = DateFormat(this.queryParam.ssde0003, "YYYY-MM-DD")
                this.searchQuery();
            },
            selectChange({row}) {
                this.$refs.xTree.setRadioRow(row);
                this.selectedData = row;
            },
            generate() {
                this.$refs.modal01.generate()
            },
            handleAdd() {
                this.$refs.modal02.handleAdd()
            },
            handleEdit() {
                this.$refs.modal02.handleEdit(this.selectedData)
            },
            handleView() {
                this.$refs.modal02.handleView(this.selectedData)
            },
            handleDelete() {
                let that = this;
                if (that.selectedData == '' || that.selectedData == undefined) {
                    that.$Message.error('请选中一条数据!')
                    return false;
                } else {
                    this.$Modal.confirm({
                        title: '确定删除吗？',
                        onOk: () => {
                            postAction(that.url.delete, that.selectedData).then((res) => {
                                if (res.data.errcode == 0) {
                                    if (res.data.data.success == '0'){
                                        that.$Message.error(res.data.data.msg);
                                    }else if (res.data.data.success == '1'){
                                        that.$Message.success(res.data.data.msg);
                                    }else{
                                        that.$Message.error(res.data.data.msg);
                                    }
                                } else {
                                    that.$Message.error("删除失败！");
                                }
                            }).finally(() => {
                                this.loadData();
                                this.selectedData = null
                            });
                        }
                    })
                }
            },
            ok() {
                this.loadData();
            },
        },
        created() {
            let that = this
            this.loadData();
            // 判断当前登录帐号级别,
            postAction('/api/ac/subsistence/ss13008Service/checkLoginUser', {}).then((res) => {
                if (res.data.errcode == 0){
                    if (res.data.data.showGenerate == '1'){
                        that.showGenerate = true
                    }else{
                        that.showGenerate = false
                    }
                }else{
                    that.$Message.error("当前账号区划异常, 请联系管理员");
                }
            });

        },
        updated() {
        }
    }
</script>
<style scoped>
    /deep/ .ivu-form-item-error-tip {
        display: none;
    }

    .itemStyle {
        width: 180px
    }

    .head-img1 {
        height: 200px;
        width: 250px;
        margin-top: 15px;
    }

    .head-img {
        height: 200px;
        width: 250px;
    }

    .imgBackColor {
        background-color: WhiteSmoke;
        height: 250px;
    }

    .positiveTDiv {
        height: 240px;
        width: 75px;
        line-height: 240px;
        background-color: #7CCD7C;
        margin-bottom: 10px;
        color: white;
        font-size: 14px;
        font-weight: 700;
    }

    /deep/ .ivu-table .demo-table-info-cell-age {
        background-color: #ff6600;
        color: #fff;
    }

    /deep/ .ivu-table .demo-table-info-cell-ssfc0015_name {
        background-color: #f33e3e;
        color: #fff;
    }
</style>
